package com.zb.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zb.common.mapper.OperationLogMapper;
import com.zb.common.po.enums.PageSize;
import com.zb.common.po.model.OperationLog;
import com.zb.common.po.query.OperationLogQuery;
import com.zb.common.utils.PaginationResult;
import com.zb.common.utils.SimplePage;
import com.zb.service.OperationLogService;

@Service(value = "operationLogService")
public class OperationLogServiceImpl implements OperationLogService {

    @Resource
    private OperationLogMapper operationLogMapper;

    @Override
    public PaginationResult<OperationLog> findLogListByPage(
            OperationLogQuery query) {
        int count = this.operationLogMapper.selectLogCount(query);
        int pageSize = PageSize.SIZE20.getSize();
        int pageNo = 0;
        if (null != query.getPageNo()) {
            pageNo = query.getPageNo();
        }
        SimplePage page = new SimplePage(pageNo, count, pageSize);
        query.setPage(page);
        List<OperationLog> list = this.operationLogMapper.selectLogList(query);
        PaginationResult<OperationLog> result = new PaginationResult<OperationLog>(
                page, list);
        return result;
    }

}
